package org.komarichin.services;

import org.komarichin.beans.ILanguage;
import org.komarichin.beans.dao.ILanguageDAO;
import org.komarichin.beans.service.ILanguageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collection;

/**
 * User: Mykhaylo Komarichyn
 * Date: 03.02.2010
 * Time: 14:39:44
 */
@Service
public class LanguageService<PK> implements ILanguageService<PK> {

    private static final long serialVersionUID = 1666046324190521581L;

    @Autowired
    private ILanguageDAO<ILanguage<PK>, PK> languageDAO;


    @Override
    public ILanguage<PK> save(ILanguage<PK> lang) {
        return languageDAO.save(lang);
    }

    @Override
    public void saveOrUpdate(ILanguage<PK> lang) {
        languageDAO.saveOrUpdate(lang);
    }

    @Override
    public void delete(ILanguage<PK> lang) {
        delete(lang.getId());
    }

    @Override
    public void delete(PK id) {
        languageDAO.remove(id);
    }

    @Override
    public ILanguage<PK> findById(PK id) {
        return languageDAO.findById(id);
    }

    @Override
    public ILanguage<PK> findByName(String name) {
        return languageDAO.findByName(name);
    }

    @Override
    public Collection<ILanguage<PK>> getAll() {
        return languageDAO.getAll();
    }

    @Override
    public ILanguage<PK> newInstance() {
        return languageDAO.newInstance();
    }
}
